package com.quarantine.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.quarantine.dao.memberDao;
import com.quarantine.model.member;

@Component
@Transactional
public class MemberManager {
	
	private memberDao memberDao;

	public memberDao getMemberDao() {
		return memberDao;
	}
	
	@Autowired
	public void setMemberDao(memberDao memberDao) {
		this.memberDao = memberDao;
	}
	/***
	 * 保存
	 */
	
	public void save(member entity) {
		memberDao.save(entity);
		
	}
	    /**
	     * 根据id查找
	     */
	    @Transactional  
		public member getById(String id) {
			return memberDao.findUniqueBy("id", id);
		}
	    
	    /***
	     * 显示会员列表
	     * @param page
	     * @return
	     */
	    @Transactional 
	    public Page<member> getList(final Page<member>page ,String category) {
		return memberDao.findPage(page, "from member where category=? order by edit_time desc",category);
	}
	    /***
	     * 显示全部会员列表
	     * @param page
	     * @return
	     */
	    @Transactional 
	    public Page<member> getall(final Page<member>page) {
		return memberDao.findPage(page, "from member order by edit_time desc");
	}
	    @Transactional 
	    public Page<member> getList1(final Page<member>page) {
		return memberDao.findPage(page, "from member where category='副会长单位' order by edit_time desc");
	}
	    @Transactional 
	    public Page<member> getList2(final Page<member>page) {
		return memberDao.findPage(page, "from member where category='常务理事单位' order by edit_time desc");
	}
	    @Transactional 
	    public Page<member> getList3(final Page<member>page) {
		return memberDao.findPage(page, "from member where category='理事单位' order by edit_time desc");
	}
	    @Transactional 
	    public Page<member> getList4(final Page<member>page) {
		return memberDao.findPage(page, "from member where category='一般会员单位'  order by edit_time desc");
	}
	    @Transactional      
	    /**
	     * 根据id来删除
	     */
	    public void delete(String id){
	    	memberDao.delete(id);
	    }

		 
	

}
